<template>
    <div class="app-container">
        <el-form size="mini" :inline="true" label-width="68px">

            <el-form-item label="专业">
                <el-select style="width: 400px;" @change="changeMajor" clearable size="mini" v-model="queryParams.majorId">
                    <el-option v-for="(v, i) in major_list" :key="i" :value="v.majorId" :label="v.majorName">
                    </el-option>
                </el-select>
            </el-form-item>

            <el-form-item label="班级">
                <el-select style="width: 400px;" clearable size="mini" v-model="queryParams.classId"
                    placeholder="请先选择专业再选择班级">
                    <el-option v-for="(v, i) in class_list" :key="i" :value="v.classId" :label="v.className">
                    </el-option>
                </el-select>
            </el-form-item>

            <el-form-item label="年级">
                <el-select clearable size="mini" v-model="queryParams.gradeId">
                    <el-option v-for="(v, i) in grade_list" :key="i" :value="v.gradeId" :label="v.gradeName">
                    </el-option>
                </el-select>
            </el-form-item>

            <el-form-item label="学号">
                <el-input v-model="queryParams.stuNo"></el-input>
            </el-form-item>

            <el-form-item label="姓名">
                <el-input v-model="queryParams.stuName"></el-input>
            </el-form-item>

            <el-form-item label="审核状态">
                <el-select v-model="queryParams.status">
                    <el-option v-for="dict in dict.type.audius_detail_type" :key="dict.value" :label="dict.label"
                        :value="parseInt(dict.value)"></el-option>
                </el-select>
            </el-form-item>

            <el-form-item label="">
                <el-button size="mini" icon="el-icon-search" @click="getList">搜索</el-button>
                <el-button size="mini" icon="el-icon-refresh" @click="doRefresh">刷新</el-button>
            </el-form-item>

        </el-form>

        <el-table v-loading="loading" :data="tableData">
            <el-table-column label="专业" align="center" prop="majorName" width="280" />
            <el-table-column label="班级" align="center" prop="className" width="280" />
            <el-table-column label="辅导员" align="center" prop="teacherName" width="100" />
            <el-table-column label="学生姓名" align="center" prop="stuName" width="100" />
            <el-table-column label="提交时间" align="center" prop="createTime" width="180" />
            <el-table-column label="加分项" align="center" prop="ruleName" />
            <el-table-column label="分数" align="center" prop="iamScore" />
            <el-table-column label="审核状态" align="center" prop="auditStatus">
                <template slot-scope="scope">
                    <dict-tag :options="dict.type.audius_detail_type" :value="scope.row.auditStatus" />
                </template>
            </el-table-column>
        </el-table>


        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
            @pagination="getList" />


    </div>
</template>
<script>
import { listOwnCollegeAudit, listOwnMajor, listOwnClass } from "@/api/stuCQS/info-fill/cqScore";
import { listEnableYear as listYear } from "@/api/stuCQS/basedata/year";
import { listGrade } from "@/api/stuCQS/basedata/grade";


import { isEmpty } from "@/api/helpFunc";
import lodash from "lodash";

export default {
    name: "xw-iam",
    dicts: ['audius_detail_type'],
    data() {
        return {
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                majorId: null,
                classId: null,
                stuYearId: null,
                gradeId: null,
                stuName: "",
                stuNo: "",
                status:null
            },

            major_list: [],
            class_list: [],
            year_list: [],
            grade_list: [],

            loading: false,
            tableData: [],
            total: 0

        }
    },
    created() {
        this.getList();
        this.listOwnMajor();
        this.listYear();
        this.listGrade();
    },
    methods: {
        async getList() {
            this.loading = true;
            let res = await listOwnCollegeAudit(this.queryParams);
            this.loading = false;

            if (res.code == 200) {
                this.tableData = lodash.cloneDeep(res.rows);
                this.total = res.total;
            }
        },
        async doRefresh() {
            this.queryParams = {
                pageNum: 1,
                pageSize: 10,
                majorId: null,
                classId: null,
                stuYearId: null,
                gradeId: null,
                stuName: "",
                stuNo: "",
                status:null
            };
            await this.getList();
        },
        async listOwnMajor() {
            let res = await listOwnMajor();
            if (res.code == 200) {
                this.major_list = lodash.cloneDeep(res.data);
            }
        },
        async changeMajor(major) {
            console.log(major)
            if (isEmpty(major)) {
                this.class_list = [];
                this.queryParams.classId = null;
            } else {
                let res = await listOwnClass(major);
                if (res.code == 200) {
                    this.class_list = lodash.cloneDeep(res.data);
                }
            }
        },
        async listYear() {
            let res = await listYear();
            if (res.code == 200) {
                this.year_list = lodash.cloneDeep(res.rows);
            }
        },
        async listGrade() {
            let res = await listGrade();
            if (res.code == 200) {
                this.grade_list = lodash.cloneDeep(res.rows);
            }
        }
    }
}
</script>